<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="资金类型
" prop="typeOfFunds">
        <el-input
          v-model="queryParams.typeOfFunds"
          placeholder="请输入资金类型
"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同编号" prop="contractNumber">
        <el-input
          v-model="queryParams.contractNumber"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同类型
" prop="contractType">
        <el-select v-model="queryParams.contractType" placeholder="请选择合同类型
" clearable>
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="付款日期" prop="paymentDate">
        <el-date-picker clearable
          v-model="queryParams.paymentDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择付款日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="付款方式" prop="paymentMethod">
        <el-input
          v-model="queryParams.paymentMethod"
          placeholder="请输入付款方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="本次付款金额" prop="paymentAmount">
        <el-input
          v-model="queryParams.paymentAmount"
          placeholder="请输入本次付款金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购订单编号" prop="purchaseOrderNumber">
        <el-input
          v-model="queryParams.purchaseOrderNumber"
          placeholder="请输入采购订单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购需求" prop="procurementDemand">
        <el-input
          v-model="queryParams.procurementDemand"
          placeholder="请输入采购需求"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单日期" prop="orderDate">
        <el-date-picker clearable
          v-model="queryParams.orderDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择订单日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="预计到货日期" prop="expectedDeliveryDate">
        <el-date-picker clearable
          v-model="queryParams.expectedDeliveryDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择预计到货日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="申请人" prop="applicant">
        <el-input
          v-model="queryParams.applicant"
          placeholder="请输入申请人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申请人id" prop="applicantId">
        <el-input
          v-model="queryParams.applicantId"
          placeholder="请输入申请人id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申请人所属部门" prop="applicantDept">
        <el-input
          v-model="queryParams.applicantDept"
          placeholder="请输入申请人所属部门"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申请人所属部门id" prop="applicantDeptId">
        <el-input
          v-model="queryParams.applicantDeptId"
          placeholder="请输入申请人所属部门id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购申请单号" prop="purchaseRequisitionNumber">
        <el-input
          v-model="queryParams.purchaseRequisitionNumber"
          placeholder="请输入采购申请单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购状态" prop="procurementStatus">
        <el-select v-model="queryParams.procurementStatus" placeholder="请选择采购状态" clearable>
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="采购合计总金额(元)" prop="totalPurchaseAmount">
        <el-input
          v-model="queryParams.totalPurchaseAmount"
          placeholder="请输入采购合计总金额(元)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合计总金额(大写)元" prop="totalAmountInWords">
        <el-input
          v-model="queryParams.totalAmountInWords"
          placeholder="请输入合计总金额(大写)元"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否客户寄样" prop="customerSendsSamplesOr">
        <el-input
          v-model="queryParams.customerSendsSamplesOr"
          placeholder="请输入是否客户寄样"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否有运费" prop="freightOr">
        <el-input
          v-model="queryParams.freightOr"
          placeholder="请输入是否有运费"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合计运费(元)" prop="totalFreightCost">
        <el-input
          v-model="queryParams.totalFreightCost"
          placeholder="请输入合计运费(元)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购单价最小值" prop="miniPurchaseUnitPrice">
        <el-input
          v-model="queryParams.miniPurchaseUnitPrice"
          placeholder="请输入采购单价最小值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购需求总数" prop="totalProcurementRequire">
        <el-input
          v-model="queryParams.totalProcurementRequire"
          placeholder="请输入采购需求总数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="已入库总数" prop="totalStoredItems">
        <el-input
          v-model="queryParams.totalStoredItems"
          placeholder="请输入已入库总数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="实际应付总金额" prop="totalPayableAmount">
        <el-input
          v-model="queryParams.totalPayableAmount"
          placeholder="请输入实际应付总金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="已付金额(元)" prop="amountPaid">
        <el-input
          v-model="queryParams.amountPaid"
          placeholder="请输入已付金额(元)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="未付金额(元)" prop="unpaidAmount">
        <el-input
          v-model="queryParams.unpaidAmount"
          placeholder="请输入未付金额(元)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否使用备用金" prop="reserveFundOr">
        <el-input
          v-model="queryParams.reserveFundOr"
          placeholder="请输入是否使用备用金"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="支付方式" prop="paymentType">
        <el-select v-model="queryParams.paymentType" placeholder="请选择支付方式" clearable>
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="支付金额" prop="paymentMoney">
        <el-input
          v-model="queryParams.paymentMoney"
          placeholder="请输入支付金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否需要报销" prop="reimburseOr">
        <el-input
          v-model="queryParams.reimburseOr"
          placeholder="请输入是否需要报销"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报销方式" prop="reimburseType">
        <el-select v-model="queryParams.reimburseType" placeholder="请选择报销方式" clearable>
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="支付宝账号" prop="alipayAccount">
        <el-input
          v-model="queryParams.alipayAccount"
          placeholder="请输入支付宝账号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="收款码" prop="paymentCode">
        <el-input
          v-model="queryParams.paymentCode"
          placeholder="请输入收款码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开户姓名" prop="accountName">
        <el-input
          v-model="queryParams.accountName"
          placeholder="请输入开户姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="银行卡开户行" prop="bankCardOpeningBank">
        <el-input
          v-model="queryParams.bankCardOpeningBank"
          placeholder="请输入银行卡开户行"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="银行卡号" prop="bankCardNumber">
        <el-input
          v-model="queryParams.bankCardNumber"
          placeholder="请输入银行卡号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审批结果" prop="approvalResult">
        <el-input
          v-model="queryParams.approvalResult"
          placeholder="请输入审批结果"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审批时间" prop="approvalTime">
        <el-date-picker clearable
          v-model="queryParams.approvalTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择审批时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="审批人" prop="approver">
        <el-input
          v-model="queryParams.approver"
          placeholder="请输入审批人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审批人id" prop="approverId">
        <el-input
          v-model="queryParams.approverId"
          placeholder="请输入审批人id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="不通过原因" prop="notPassingReason">
        <el-input
          v-model="queryParams.notPassingReason"
          placeholder="请输入不通过原因"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="部门状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择部门状态" clearable>
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['mes:md:order:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['mes:md:order:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['mes:md:order:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
            <el-button
              type="success"
              plain
              icon="el-icon-refresh"
              size="mini"
              @click="handleSync"
             v-hasPermi="['mes:md:order:sync']"
            >数据同步</el-button>
            </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['mes:md:order:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="sequenceNum" />
      <!-- <el-table-column label="采购订单唯一值_id" align="center" prop="purcId" />
      <el-table-column label="资金类型
" align="center" prop="typeOfFunds" />
      <el-table-column label="合同编号" align="center" prop="contractNumber" />
      <el-table-column label="合同类型
" align="center" prop="contractType" />
      <el-table-column label="付款日期" align="center" prop="paymentDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.paymentDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="付款方式" align="center" prop="paymentMethod" />
      <el-table-column label="本次付款金额" align="center" prop="paymentAmount" /> -->
      <!-- <el-table-column label="采购订单编号" align="center" prop="purchaseOrderNumber" /> -->


     <el-table-column prop="purchaseOrderNumber" label="采购申请单号" width="180">

                 <template slot-scope="scope">
                          <span @click="handlepurchaseOrderNumberClick(scope.row.purchaseOrderNumber)" class="highlight-link">{{ scope.row.purchaseOrderNumber }}</span>
                 </template>

      </el-table-column>



      <el-table-column label="采购需求" align="center" prop="procurementDemand" />
      <el-table-column label="订单日期" align="center" prop="orderDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="预计到货日期" align="center" prop="expectedDeliveryDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.expectedDeliveryDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="申请人" align="center" prop="applicant" />
      <el-table-column label="申请人id" align="center" prop="applicantId" />
      <el-table-column label="申请人所属部门" align="center" prop="applicantDept" />
      <el-table-column label="申请人所属部门id" align="center" prop="applicantDeptId" />
      <el-table-column label="采购申请单号" align="center" prop="purchaseRequisitionNumber" />
      <el-table-column label="采购状态" align="center" prop="procurementStatus" />
      <el-table-column label="采购合计总金额(元)" align="center" prop="totalPurchaseAmount" />
      <el-table-column label="合计总金额(大写)元" align="center" prop="totalAmountInWords" />
      <el-table-column label="是否客户寄样" align="center" prop="customerSendsSamplesOr" />
      <el-table-column label="是否有运费" align="center" prop="freightOr" />
      <el-table-column label="合计运费(元)" align="center" prop="totalFreightCost" />
      <el-table-column label="采购单价最小值" align="center" prop="miniPurchaseUnitPrice" />
      <el-table-column label="采购需求总数" align="center" prop="totalProcurementRequire" />
      <el-table-column label="已入库总数" align="center" prop="totalStoredItems" />
      <el-table-column label="实际应付总金额" align="center" prop="totalPayableAmount" />
      <el-table-column label="已付金额(元)" align="center" prop="amountPaid" />
      <el-table-column label="未付金额(元)" align="center" prop="unpaidAmount" />
      <el-table-column label="是否使用备用金" align="center" prop="reserveFundOr" />
      <el-table-column label="支付方式" align="center" prop="paymentType" />
      <el-table-column label="支付金额" align="center" prop="paymentMoney" />
      <el-table-column label="支付凭证" align="center" prop="paymentVoucher" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="是否需要报销" align="center" prop="reimburseOr" />
      <el-table-column label="报销方式" align="center" prop="reimburseType" />
      <el-table-column label="支付宝账号" align="center" prop="alipayAccount" />
      <el-table-column label="收款码" align="center" prop="paymentCode" />
      <el-table-column label="开户姓名" align="center" prop="accountName" />
      <el-table-column label="银行卡开户行" align="center" prop="bankCardOpeningBank" />
      <el-table-column label="银行卡号" align="center" prop="bankCardNumber" />
      <el-table-column label="审批结果" align="center" prop="approvalResult" />
      <el-table-column label="审批时间" align="center" prop="approvalTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.approvalTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审批人" align="center" prop="approver" />
      <el-table-column label="审批人id" align="center" prop="approverId" />
      <el-table-column label="不通过原因" align="center" prop="notPassingReason" />
      <el-table-column label="部门状态" align="center" prop="status" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">

        </el-table-column>
                <!-- 其他列根据需要添加 -->
        </el-table>


         <!-- 对话框 -->
            <el-dialog :visible.sync="dialogVisible" title="采购订单详情" width="80%">
              <el-tabs type="border-card" v-if="form.purchaseOrderNumber != null">
                <el-tab-pane label="采购产品明细">
                  <el-table :data="mdPurcOrderPurcList" style="width: 100%">
                    <el-table-column prop="purchaseOrderNumber" label="采购订单编号"></el-table-column>
                    <el-table-column prop="purcSupplierCode" label="供应商名称"></el-table-column>
                    <el-table-column prop="purcMaterialName" label="物料名称"></el-table-column>
                    <el-table-column prop="purcMaterialCode" label="物料编码"></el-table-column>
                    <el-table-column prop="purcQuantityDemand" label="采购数量需求"></el-table-column>
                    <!-- 其他列 -->
                  </el-table>
                </el-tab-pane>
                <el-tab-pane label="类型列表">
                  <el-table :data="mdPurcOrderTypeList" style="width: 100%">
                    <el-table-column prop="purchaseOrderNumber" label="采购订单编号"></el-table-column>
                    <el-table-column prop="typeListType" label="类型"></el-table-column>
                    <el-table-column prop="typeListSupplier" label="供应商"></el-table-column>
                    <el-table-column prop="typeListSupplierCode" label="供应商编码"></el-table-column>
                    <!-- 其他列 -->
                  </el-table>
                </el-tab-pane>
              </el-tabs>
              <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">关闭</el-button>
              </span>
            </el-dialog>





        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['mes:md:order:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['mes:md:order:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="资金类型
" prop="typeOfFunds">
          <el-input v-model="form.typeOfFunds" placeholder="请输入资金类型
" />
        </el-form-item>
        <el-form-item label="合同编号" prop="contractNumber">
          <el-input v-model="form.contractNumber" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="合同类型
" prop="contractType">
          <el-select v-model="form.contractType" placeholder="请选择合同类型
">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="付款日期" prop="paymentDate">
          <el-date-picker clearable
            v-model="form.paymentDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择付款日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="付款方式" prop="paymentMethod">
          <el-input v-model="form.paymentMethod" placeholder="请输入付款方式" />
        </el-form-item>
        <el-form-item label="本次付款金额" prop="paymentAmount">
          <el-input v-model="form.paymentAmount" placeholder="请输入本次付款金额" />
        </el-form-item>
        <el-form-item label="采购订单编号" prop="purchaseOrderNumber">
          <el-input v-model="form.purchaseOrderNumber" placeholder="请输入采购订单编号" />
        </el-form-item>
        <el-form-item label="采购需求" prop="procurementDemand">
          <el-input v-model="form.procurementDemand" placeholder="请输入采购需求" />
        </el-form-item>
        <el-form-item label="订单日期" prop="orderDate">
          <el-date-picker clearable
            v-model="form.orderDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择订单日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="预计到货日期" prop="expectedDeliveryDate">
          <el-date-picker clearable
            v-model="form.expectedDeliveryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择预计到货日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="申请人" prop="applicant">
          <el-input v-model="form.applicant" placeholder="请输入申请人" />
        </el-form-item>
        <el-form-item label="申请人id" prop="applicantId">
          <el-input v-model="form.applicantId" placeholder="请输入申请人id" />
        </el-form-item>
        <el-form-item label="申请人所属部门" prop="applicantDept">
          <el-input v-model="form.applicantDept" placeholder="请输入申请人所属部门" />
        </el-form-item>
        <el-form-item label="申请人所属部门id" prop="applicantDeptId">
          <el-input v-model="form.applicantDeptId" placeholder="请输入申请人所属部门id" />
        </el-form-item>
        <el-form-item label="采购申请单号" prop="purchaseRequisitionNumber">
          <el-input v-model="form.purchaseRequisitionNumber" placeholder="请输入采购申请单号" />
        </el-form-item>
        <el-form-item label="采购状态">
          <el-radio-group v-model="form.procurementStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="采购合计总金额(元)" prop="totalPurchaseAmount">
          <el-input v-model="form.totalPurchaseAmount" placeholder="请输入采购合计总金额(元)" />
        </el-form-item>
        <el-form-item label="合计总金额(大写)元" prop="totalAmountInWords">
          <el-input v-model="form.totalAmountInWords" placeholder="请输入合计总金额(大写)元" />
        </el-form-item>
        <el-form-item label="是否客户寄样" prop="customerSendsSamplesOr">
          <el-input v-model="form.customerSendsSamplesOr" placeholder="请输入是否客户寄样" />
        </el-form-item>
        <el-form-item label="是否有运费" prop="freightOr">
          <el-input v-model="form.freightOr" placeholder="请输入是否有运费" />
        </el-form-item>
        <el-form-item label="合计运费(元)" prop="totalFreightCost">
          <el-input v-model="form.totalFreightCost" placeholder="请输入合计运费(元)" />
        </el-form-item>
        <el-form-item label="采购单价最小值" prop="miniPurchaseUnitPrice">
          <el-input v-model="form.miniPurchaseUnitPrice" placeholder="请输入采购单价最小值" />
        </el-form-item>
        <el-form-item label="采购需求总数" prop="totalProcurementRequire">
          <el-input v-model="form.totalProcurementRequire" placeholder="请输入采购需求总数" />
        </el-form-item>
        <el-form-item label="已入库总数" prop="totalStoredItems">
          <el-input v-model="form.totalStoredItems" placeholder="请输入已入库总数" />
        </el-form-item>
        <el-form-item label="实际应付总金额" prop="totalPayableAmount">
          <el-input v-model="form.totalPayableAmount" placeholder="请输入实际应付总金额" />
        </el-form-item>
        <el-form-item label="已付金额(元)" prop="amountPaid">
          <el-input v-model="form.amountPaid" placeholder="请输入已付金额(元)" />
        </el-form-item>
        <el-form-item label="未付金额(元)" prop="unpaidAmount">
          <el-input v-model="form.unpaidAmount" placeholder="请输入未付金额(元)" />
        </el-form-item>
        <el-form-item label="是否使用备用金" prop="reserveFundOr">
          <el-input v-model="form.reserveFundOr" placeholder="请输入是否使用备用金" />
        </el-form-item>
        <el-form-item label="支付方式" prop="paymentType">
          <el-select v-model="form.paymentType" placeholder="请选择支付方式">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="支付金额" prop="paymentMoney">
          <el-input v-model="form.paymentMoney" placeholder="请输入支付金额" />
        </el-form-item>
        <el-form-item label="支付凭证" prop="paymentVoucher">
          <el-input v-model="form.paymentVoucher" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="是否需要报销" prop="reimburseOr">
          <el-input v-model="form.reimburseOr" placeholder="请输入是否需要报销" />
        </el-form-item>
        <el-form-item label="报销方式" prop="reimburseType">
          <el-select v-model="form.reimburseType" placeholder="请选择报销方式">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="支付宝账号" prop="alipayAccount">
          <el-input v-model="form.alipayAccount" placeholder="请输入支付宝账号" />
        </el-form-item>
        <el-form-item label="收款码" prop="paymentCode">
          <el-input v-model="form.paymentCode" placeholder="请输入收款码" />
        </el-form-item>
        <el-form-item label="开户姓名" prop="accountName">
          <el-input v-model="form.accountName" placeholder="请输入开户姓名" />
        </el-form-item>
        <el-form-item label="银行卡开户行" prop="bankCardOpeningBank">
          <el-input v-model="form.bankCardOpeningBank" placeholder="请输入银行卡开户行" />
        </el-form-item>
        <el-form-item label="银行卡号" prop="bankCardNumber">
          <el-input v-model="form.bankCardNumber" placeholder="请输入银行卡号" />
        </el-form-item>
        <el-form-item label="审批结果" prop="approvalResult">
          <el-input v-model="form.approvalResult" placeholder="请输入审批结果" />
        </el-form-item>
        <el-form-item label="审批时间" prop="approvalTime">
          <el-date-picker clearable
            v-model="form.approvalTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择审批时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="审批人" prop="approver">
          <el-input v-model="form.approver" placeholder="请输入审批人" />
        </el-form-item>
        <el-form-item label="审批人id" prop="approverId">
          <el-input v-model="form.approverId" placeholder="请输入审批人id" />
        </el-form-item>
        <el-form-item label="不通过原因" prop="notPassingReason">
          <el-input v-model="form.notPassingReason" placeholder="请输入不通过原因" />
        </el-form-item>
        <el-form-item label="部门状态">
          <el-radio-group v-model="form.status">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="删除标志" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入删除标志" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>


<style scoped>.highlight-column {
  background-color: #f0f9eb; /* 背景颜色 */
}

.highlight-link {
  color: blue;
  cursor: pointer;
  text-decoration: underline;
}
</style>




<script>
import { listOrder, getOrder, delOrder, addOrder, updateOrder,syncPurcOrder,getMdPurcOrderPurcList ,getMdPurcOrderTypeList} from "@/api/mes/md/purcorder";

export default {
  name: "Order",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      orderList: [],
      loading: false,
      queryParams: {},
      dialogVisible: false,
      form: {},
      mdPurcOrderPurcList: [],
      mdPurcOrderTypeList: [],




      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        typeOfFunds: null,        contractNumber: null,        contractType: null,        paymentDate: null,        paymentMethod: null,        paymentAmount: null,        purchaseOrderNumber: null,        procurementDemand: null,        orderDate: null,        expectedDeliveryDate: null,        applicant: null,        applicantId: null,        applicantDept: null,        applicantDeptId: null,        purchaseRequisitionNumber: null,        procurementStatus: null,        totalPurchaseAmount: null,        totalAmountInWords: null,        customerSendsSamplesOr: null,        freightOr: null,        totalFreightCost: null,        miniPurchaseUnitPrice: null,        totalProcurementRequire: null,        totalStoredItems: null,        totalPayableAmount: null,        amountPaid: null,        unpaidAmount: null,        reserveFundOr: null,        paymentType: null,        paymentMoney: null,        paymentVoucher: null,        reimburseOr: null,        reimburseType: null,        alipayAccount: null,        paymentCode: null,        accountName: null,        bankCardOpeningBank: null,        bankCardNumber: null,        approvalResult: null,        approvalTime: null,        approver: null,        approverId: null,        notPassingReason: null,        status: null,      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {

    handlepurchaseOrderNumberClick(purchaseOrderNumber) {
      console.log("purchaseOrderNumber>>"+purchaseOrderNumber)
         this.dialogVisible = true;
         this.form.purchaseOrderNumber = purchaseOrderNumber;
         this.getMdPurcOrderPurcList(purchaseOrderNumber);
         this.getMdPurcOrderTypeList(purchaseOrderNumber);
       },
       getMdPurcOrderPurcList(purchaseOrderNumber) {
         getMdPurcOrderPurcList({ purchaseOrderNumber }).then(response => {
           this.mdPurcOrderPurcList = response.rows;
         });
       },
       getMdPurcOrderTypeList(purchaseOrderNumber) {
             getMdPurcOrderTypeList({ purchaseOrderNumber }).then(response => {
               this.mdPurcOrderTypeList = response.rows;
             });
           },




    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listOrder(this.queryParams).then(response => {
        this.orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        sequenceNum: null,        purcId: null,        typeOfFunds: null,        contractNumber: null,        contractType: null,        paymentDate: null,        paymentMethod: null,        paymentAmount: null,        purchaseOrderNumber: null,        procurementDemand: null,        orderDate: null,        expectedDeliveryDate: null,        applicant: null,        applicantId: null,        applicantDept: null,        applicantDeptId: null,        purchaseRequisitionNumber: null,        procurementStatus: "0",        totalPurchaseAmount: null,        totalAmountInWords: null,        customerSendsSamplesOr: null,        freightOr: null,        totalFreightCost: null,        miniPurchaseUnitPrice: null,        totalProcurementRequire: null,        totalStoredItems: null,        totalPayableAmount: null,        amountPaid: null,        unpaidAmount: null,        reserveFundOr: null,        paymentType: null,        paymentMoney: null,        paymentVoucher: null,        remark: null,        reimburseOr: null,        reimburseType: null,        alipayAccount: null,        paymentCode: null,        accountName: null,        bankCardOpeningBank: null,        bankCardNumber: null,        approvalResult: null,        approvalTime: null,        approver: null,        approverId: null,        notPassingReason: null,        status: "0",        delFlag: null,        createBy: null,        createTime: null,        updateBy: null,        updateTime: null      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.sequenceNum)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加【请填写功能名称】";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const sequenceNum = row.sequenceNum || this.ids
      getOrder(sequenceNum).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改【请填写功能名称】";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.sequenceNum != null) {
            updateOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const sequenceNums = row.sequenceNum || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + sequenceNums + '"的数据项？').then(function() {
        return delOrder(sequenceNums);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 同步数据按钮操作 */
    handleSync() {
            if(this.loading){
              this.$modal.message("正常进行中，请不要重复点击...")
            }
            this.loading = true;
            this.$modal.confirm('是否确认同步数据？').then(function() {
              return syncPurcOrder();
            }).then(() => {
              this.getList();
              this.$modal.msgSuccess("同步成功");
            }).catch(() => {});
          },
    /** 导出按钮操作 */
    handleExport() {
      this.download('/mes/md/purcorder/export', {
        ...this.queryParams
      }, `order_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
